home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / NetBSD / docs-netbsd / Mailinglist-Archive / 1994-08.gz / 1994-08 / 000028_owner-current-u…s.berkeley.edu_Mon Aug 1 13:05:53 1994.msg < prev    next >
Text File  |  1994-10-16  |  11KB  |  331 lines

  1. From: matthieu@laas.fr (Matthieu Herrb)
  2. To: current-users@sun-lamp.cs.berkeley.edu
  3. Subject: pccons patch for non-US keyboards.
  4. X-Organization: LAAS-CNRS Toulouse, France
  5. X-Phone: (33) 61 33 63 30
  6. Content-Length: 10569
  7. Sender: owner-current-users@sun-lamp.cs.berkeley.edu
  8.  
  9.  
  10. Since I got more than 2 requests for it, here is my patch to
  11. pcccons. 
  12.  
  13. It's not french specific, but it only has a mapping defined for my
  14. french keyboard. To use it with another keyboard, you'll first have to
  15. add your own table:
  16.  
  17. 1. Choose an option name (for example GERMAN_KBD) 
  18. 2. At the beginning of pcccons.c add ''|| defined(GERMAN_KBD)'' after
  19.    #if defined(FRENCH_KBD) to enable NONUS_KBD and DISPLAY_ISO8859
  20. 3. Look for 'XXXX Add tables' to see where to add your table. For
  21.    non-us keyboards the struct scan_def as one more field to hold the
  22.    Alt-GR map. Insert you definition of the scan_codes[] array between
  23.    a set of #ifdef GERMAN_KBD .. #endif.
  24. 4. Add 'option GERMAN_KBD' to your kernel config file and rebuild your
  25.    kernel. 
  26. 5. Reboot.
  27.  
  28. If you're switch back from pcvt, make sure that the ttyv[0-9] entries
  29. in /etc/ttys are commented out. ttyflags -a causes a kernel crash when
  30. they are there and no kernel support for them is present.
  31.  
  32. *** /sys/arch/i386/isa/pccons.c.050594    Thu May  5 13:11:11 1994
  33. --- pccons.c    Sun Jul 31 13:20:44 1994
  34. ***************
  35. *** 81,86 ****
  36. --- 81,94 ----
  37.   
  38.   #define PCBURST 128
  39.   
  40. + /*
  41. +  * Non-US keyboards definition
  42. +  */
  43. + #if defined(FRENCH_KBD)
  44. + # define NONUS_KBD
  45. + # define DISPLAY_ISO8859
  46. + #endif
  47.   extern u_short *Crtat;            /* pointer to backing store */
  48.   static u_short *crtat;            /* pointer to current char */
  49.   static volatile u_char ack, nak;    /* Don't ask. */
  50. ***************
  51. *** 137,142 ****
  52. --- 145,153 ----
  53.   #define    FUNC        0x0100    /* function key */
  54.   #define    KP        0x0200    /* Keypad keys */
  55.   #define    NONE        0x0400    /* no function */
  56. + #ifdef NONUS_KBD
  57. + #define ALTGR           0x0040  /* Alt graphic */
  58. + #endif
  59.   
  60.   static unsigned int addr_6845 = MONO_BASE;
  61.   
  62. ***************
  63. *** 726,731 ****
  64. --- 737,764 ----
  65.       BG_MAGENTA, BG_CYAN, BG_LIGHTGREY
  66.   };
  67.   
  68. + #ifdef DISPLAY_ISO8859
  69. + static u_char iso2ibm437[] =
  70. + {
  71. +            0,     0,     0,     0,     0,     0,     0,     0,
  72. +            0,     0,     0,     0,     0,     0,     0,     0,
  73. +            0,     0,     0,     0,     0,     0,     0,     0,
  74. +            0,     0,     0,     0,     0,     0,     0,     0,
  75. +         0xff,  0xad,  0x9b,  0x9c,     0,  0x9d,     0,  0x40,
  76. +         0x6f,  0x63,  0x61,  0xae,     0,     0,     0,     0,
  77. +         0xf8,  0xf1,  0xfd,  0x33,     0,  0xe6,     0,  0xfa,
  78. +            0,  0x31,  0x6f,  0xaf,  0xac,  0xab,     0,  0xa8,
  79. +         0x41,  0x41,  0x41,  0x41,  0x8e,  0x8f,  0x92,  0x80,
  80. +         0x45,  0x90,  0x45,  0x45,  0x49,  0x49,  0x49,  0x49,
  81. +         0x81,  0xa5,  0x4f,  0x4f,  0x4f,  0x4f,  0x99,  0x4f,
  82. +         0x4f,  0x55,  0x55,  0x55,  0x9a,  0x59,     0,  0xe1,
  83. +         0x85,  0xa0,  0x83,  0x61,  0x84,  0x86,  0x91,  0x87,
  84. +         0x8a,  0x82,  0x88,  0x89,  0x8d,  0xa1,  0x8c,  0x8b,
  85. +            0,  0xa4,  0x95,  0xa2,  0x93,  0x6f,  0x94,  0x6f,
  86. +         0x6f,  0x97,  0xa3,  0x96,  0x81,  0x98,     0,     0
  87. + };
  88. + #endif
  89.   /*
  90.    * `pc3' termcap emulation.
  91.    */
  92. ***************
  93. *** 865,870 ****
  94. --- 898,907 ----
  95.                        * break to do a scroll check.
  96.                        */
  97.                       for (;;) {
  98. + #ifdef DISPLAY_ISO8859
  99. +                                if (c & 0x80) 
  100. +                                 c = iso2ibm437[c&0x7f];
  101. + #endif
  102.                           if (vs.so)
  103.                               wrtchar(c, vs.so_at);
  104.                           else
  105. ***************
  106. *** 1179,1184 ****
  107. --- 1216,1222 ----
  108.   }
  109.   
  110.   #define    CODE_SIZE    4        /* Use a max of 4 for now... */
  111. + #ifndef NONUS_KBD
  112.   typedef struct {
  113.       u_short    type;
  114.       char unshift[CODE_SIZE];
  115. ***************
  116. *** 1317,1322 ****
  117. --- 1355,1511 ----
  118.       NONE,    "",        "",        "",        /* 127 */
  119.   };
  120.   
  121. + #else /* NONUS_KBD */
  122. + typedef struct {
  123. +     u_short type;
  124. +     char unshift[CODE_SIZE];
  125. +     char shift[CODE_SIZE];
  126. +     char ctl[CODE_SIZE];
  127. +     char altgr[CODE_SIZE];
  128. + } Scan_def;
  129. + #ifdef FRENCH_KBD
  130. + static Scan_def    scan_codes[] = {
  131. +     NONE,    "",    "",    "",    "",    /* 0 unused */
  132. +     ASCII,    "\033",    "\033",    "\033", "\033", /* 1 ESCape */
  133. +     ASCII,    "&",    "1",    "&",    "",    /* 2 1 */
  134. +     ASCII,    "e'",    "2",    "\211",    "~",    /* 3 2 */
  135. +     ASCII,    "\"",    "3",    "\"",    "#",    /* 4 3 */
  136. +     ASCII,    "'",    "4",    "'",    "{",    /* 5 4 */
  137. +     ASCII,    "(",    "5",    "(",    "[",    /* 6 5 */
  138. +     ASCII,    "-",    "6",    "-",    "|",    /* 7 6 */
  139. +     ASCII,    "e!",    "7",    "\210", "`",    /* 8 7 */
  140. +     ASCII,    "_",    "8",    "\037",    "\\",    /* 9 8 */
  141. +     ASCII,    "c,",    "9",    "\207",    "^",    /* 10 9 */
  142. +     ASCII,    "a!",    "0",    "a!",    "@",    /* 11 0 */
  143. +     ASCII,    ")",    "DG",    ")",    "]",    /* 12 - */
  144. +     ASCII,    "=",    "+",    "+",    "}",    /* 13 = */
  145. +     ASCII,    "\177",    "\177",    "\010",    "\177",    /* 14 backspace */
  146. +     ASCII,    "\t",    "\177\t", "\t",    "\t",    /* 15 tab */
  147. +     ASCII,    "a",    "A",    "\001",    "a",    /* 16 q */
  148. +     ASCII,    "z",    "Z",    "\032", "z",    /* 17 w */
  149. +     ASCII,    "e",    "E",    "\005", "e",    /* 18 e */
  150. +     ASCII,    "r",    "R",    "\022", "r",    /* 19 r */
  151. +     ASCII,    "t",    "T",    "\024",    "t",    /* 20 t */
  152. +     ASCII,    "y",    "Y",    "\031",    "y",    /* 21 y */
  153. +     ASCII,    "u",    "U",    "\025", "u",    /* 22 u */
  154. +     ASCII,    "i",    "I",    "\011",    "i",    /* 23 i */
  155. +     ASCII,    "o",    "O",    "\017", "o",    /* 24 o */
  156. +     ASCII,    "p",    "P",    "\020",    "p",    /* 25 p */
  157. +     NONE,    "",    "",    "",    "",    /* 26 [ */
  158. +     ASCII,    "$",    "Pd",    "$",    "$",    /* 27 ] */
  159. +     ASCII,    "\r",    "\r",    "\n",    "\r",    /* 28 return */
  160. +     CTL,    "",    "",    "",    "",    /* 29 control */
  161. +     ASCII,    "q",    "Q",    "\021",    "q",    /* 30 a */
  162. +     ASCII,    "s",    "S",    "\023",    "s",    /* 31 s */
  163. +     ASCII,    "d",    "D",    "\004",    "d",    /* 32 d */
  164. +     ASCII,    "f",    "F",    "\006",    "f",    /* 33 f */
  165. +     ASCII,    "g",    "G",    "\007",    "g",    /* 34 g */
  166. +     ASCII,    "h",    "H",    "\010",    "h",    /* 35 h */
  167. +     ASCII,    "j",    "J",    "\n",    "j",    /* 36 j */
  168. +     ASCII,    "k",    "K",    "\013",    "k",    /* 37 k */
  169. +     ASCII,    "l",    "L",    "\014",    "l",    /* 38 l */
  170. +     ASCII,    "m",    "M",    "\r",    "m",    /* 39 ; */
  171. +     ASCII,    "u!",    "%",    "\231",    "u!",    /* 40 ' */
  172. +     ASCII,    "2S",    "",    "2S",    "2S",    /* 41 ` */
  173. +     SHIFT,    "",    "",    "",    "",    /* 42 shift */
  174. +     ASCII,    "*",    "My",    "*",    "*",    /* 43 \ */
  175. +     ASCII,    "w",    "W",    "\027",    "w",    /* 44 z */
  176. +     ASCII,    "x",    "X",    "\030",    "x",    /* 45 x */
  177. +     ASCII,    "c",    "C",    "\003",    "c",    /* 46 c */
  178. +     ASCII,    "v",    "V",    "\026",    "v",    /* 47 v */
  179. +     ASCII,    "b",    "B",    "\002",    "b",    /* 48 b */
  180. +     ASCII,    "n",    "N",    "\016",    "n",    /* 49 n */
  181. +     ASCII,    ",",    "?",    ",",    ",",    /* 50 m */
  182. +     ASCII,    ";",    ".",    ";",    ";",    /* 51 , */
  183. +     ASCII,    ":",    "/",    "\037",    ":",    /* 52 . */
  184. +     ASCII,    "!",    "PI",    "!",    "!",    /* 53 / */
  185. +     SHIFT,    "",    "",    "",    "",    /* 54 shift */
  186. +     KP,    "*",    "*",    "*",    "*",    /* 55 kp * */
  187. +     ALT,    "",    "",    "",    "",    /* 56 alt */
  188. +     ASCII,    " ",    " ",    "\000",    " ",    /* 57 space */
  189. +     CAPS,    "",    "",    "",    "",    /* 58 caps */
  190. +     FUNC,    "\033[M",    "\033[Y",    "\033[k",    "", /* 59 f1 */
  191. +     FUNC,    "\033[N",    "\033[Z",    "\033[l",    "", /* 60 f2 */
  192. +     FUNC,    "\033[O",    "\033[a",    "\033[m",    "", /* 61 f3 */
  193. +     FUNC,    "\033[P",    "\033[b",    "\033[n",    "", /* 62 f4 */
  194. +     FUNC,    "\033[Q",    "\033[c",    "\033[o",    "", /* 63 f5 */
  195. +     FUNC,    "\033[R",    "\033[d",    "\033[p",    "", /* 64 f6 */
  196. +     FUNC,    "\033[S",    "\033[e",    "\033[q",    "", /* 65 f7 */
  197. +     FUNC,    "\033[T",    "\033[f",    "\033[r",    "", /* 66 f8 */
  198. +     FUNC,    "\033[U",    "\033[g",    "\033[s",    "", /* 67 f9 */
  199. +     FUNC,    "\033[V",    "\033[h",    "\033[t",    "", /* 68 f10 */
  200. +     NUM,    "",        "",        "",        "", /* 69 num lock */
  201. +     SCROLL,    "",        "",        "",        "", /* 70 scroll lock */
  202. +     KP,    "7",        "\033[H",    "7",    "",    /* 71 kp 7 */
  203. +     KP,    "8",        "\033[A",    "8",    "",    /* 72 kp 8 */
  204. +     KP,    "9",        "\033[I",    "9",    "",    /* 73 kp 9 */
  205. +     KP,    "-",        "-",        "-",    "",    /* 74 kp - */
  206. +     KP,    "4",        "\033[D",    "4",    "",    /* 75 kp 4 */
  207. +     KP,    "5",        "\033[E",    "5",    "",    /* 76 kp 5 */
  208. +     KP,    "6",        "\033[C",    "6",    "",    /* 77 kp 6 */
  209. +     KP,    "+",        "+",        "+",    "",    /* 78 kp + */
  210. +     KP,    "1",        "\033[F",    "1",    "",    /* 79 kp 1 */
  211. +     KP,    "2",        "\033[B",    "2",    "",    /* 80 kp 2 */
  212. +     KP,    "3",        "\033[G",    "3",    "",    /* 81 kp 3 */
  213. +     KP,    "0",        "\033[L",    "0",    "",    /* 82 kp 0 */
  214. +     KP,    ".",        "\177",        ".",    "",    /* 83 kp . */
  215. +     NONE,    "",        "",        "",    "",    /* 84 0 */
  216. +     NONE,    "100",        "",        "",    "",    /* 85 0 */
  217. +     ASCII,    "<",        ">",        "<",    "<",    /* 86 < > */
  218. +     FUNC,    "\033[W",    "\033[i",    "\033[u","",    /* 87 f11 */
  219. +     FUNC,    "\033[X",    "\033[j",    "\033[v","",    /* 88 f12 */
  220. +     NONE,    "102",        "",        "",    "",    /* 89 0 */
  221. +     NONE,    "103",        "",        "",    "",    /* 90 0 */
  222. +     NONE,    "",        "",        "",    "",    /* 91 0 */
  223. +     NONE,    "",        "",        "",    "",    /* 92 0 */
  224. +     NONE,    "",        "",        "",    "",    /* 93 0 */
  225. +     NONE,    "",        "",        "",    "",    /* 94 0 */
  226. +     NONE,    "",        "",        "",    "",    /* 95 0 */
  227. +     NONE,    "",        "",        "",    "",    /* 96 0 */
  228. +     NONE,    "",        "",        "",    "",    /* 97 0 */
  229. +     NONE,    "",        "",        "",    "",    /* 98 0 */
  230. +     NONE,    "",        "",        "",    "",    /* 99 0 */
  231. +     NONE,    "",        "",        "",    "",    /* 100 */
  232. +     NONE,    "",        "",        "",    "",    /* 101 */
  233. +     NONE,    "",        "",        "",    "",    /* 102 */
  234. +     NONE,    "",        "",        "",    "",    /* 103 */
  235. +     NONE,    "",        "",        "",    "",    /* 104 */
  236. +     NONE,    "",        "",        "",    "",    /* 105 */
  237. +     NONE,    "",        "",        "",    "",    /* 106 */
  238. +     NONE,    "",        "",        "",    "",    /* 107 */
  239. +     NONE,    "",        "",        "",    "",    /* 108 */
  240. +     NONE,    "",        "",        "",    "",    /* 109 */
  241. +     NONE,    "",        "",        "",    "",    /* 110 */
  242. +     NONE,    "",        "",        "",    "",    /* 111 */
  243. +     NONE,    "",        "",        "",    "",    /* 112 */
  244. +     NONE,    "",        "",        "",    "",    /* 113 */
  245. +     NONE,    "",        "",        "",    "",    /* 114 */
  246. +     NONE,    "",        "",        "",    "",    /* 115 */
  247. +     NONE,    "",        "",        "",    "",    /* 116 */
  248. +     NONE,    "",        "",        "",    "",    /* 117 */
  249. +     NONE,    "",        "",        "",    "",    /* 118 */
  250. +     NONE,    "",        "",        "",    "",    /* 119 */
  251. +     NONE,    "",        "",        "",    "",    /* 120 */
  252. +     NONE,    "",        "",        "",    "",    /* 121 */
  253. +     NONE,    "",        "",        "",    "",    /* 122 */
  254. +     NONE,    "",        "",        "",    "",    /* 123 */
  255. +     NONE,    "",        "",        "",    "",    /* 124 */
  256. +     NONE,    "",        "",        "",    "",    /* 125 */
  257. +     NONE,    "",        "",        "",    "",    /* 126 */
  258. +     NONE,    "",        "",        "",    "",    /* 127 */
  259. + };
  260. + #endif /* FRENCH_KBD */
  261. + /*
  262. +  * XXXX Add tables for other keyboards here
  263. +  */
  264. + #endif
  265.   /*
  266.    * Get characters from the keyboard.  If none are present, return NULL.
  267.    */
  268. ***************
  269. *** 1431,1436 ****
  270. --- 1620,1630 ----
  271.               shift_state &= ~SHIFT;
  272.               break;
  273.           case ALT:
  274. + #ifdef NONUS_KBD
  275. +             if (extended) 
  276. +                     shift_state &= ~ALTGR;
  277. +             else
  278. + #endif             
  279.               shift_state &= ~ALT;
  280.               break;
  281.           case CTL:
  282. ***************
  283. *** 1475,1486 ****
  284. --- 1669,1692 ----
  285.               shift_state |= SHIFT;
  286.               break;
  287.           case ALT:
  288. + #ifdef NONUS_KBD
  289. +             if (extended)  
  290. +                     shift_state |= ALTGR;
  291. +             else
  292. + #endif
  293.               shift_state |= ALT;
  294.               break;
  295.           case CTL:
  296.               shift_state |= CTL;
  297.               break;
  298.           case ASCII:
  299. + #ifdef NONUS_KBD
  300. +             if (shift_state & ALTGR) {
  301. +                     capchar[0] = scan_codes[dt].altgr[0];
  302. +                 if (shift_state & CTL) 
  303. +                         capchar[0] &= 0x1f;
  304. +             } else
  305. + #endif
  306.               /* control has highest priority */
  307.               if (shift_state & CTL)
  308.                   capchar[0] = scan_codes[dt].ctl[0];
  309. ***************
  310. *** 1493,1498 ****
  311. --- 1699,1705 ----
  312.                   capchar[0] -= ('a' - 'A');
  313.               }
  314.               capchar[0] |= (shift_state & ALT);
  315.               extended = 0;
  316.               return capchar;
  317.           case NONE:
  318.  
  319.  
  320.  
  321.                     Matthieu